<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui">
<h:head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<title>mymsgro</title>
	<link rel="stylesheet" type="text/css" href="css/main.css" />
	<link rel="stylesheet" type="text/css" href="css/meniu.css" />
	<link rel="stylesheet" type="text/css" href="css/style.css" />

</h:head>
<h:body>

	<ui:include src="header.xhtml" />

	<h:panelGroup layout="block" id="content">

		<ui:include src="leftMenu.xhtml" />

		<h:panelGroup layout="block" id="contenRight">
<f:event type="preRenderView" listener="#{surveyCreateBean.preRenderView}"/>
			<h:panelGroup layout="block" id="header" style="margin-top: 20px;">
				<ul>
					<li id="selected"><a>Survey Answers Statistics</a></li>
				</ul>
			</h:panelGroup>

			<h:panelGroup layout="block" id="contentTab">

				<h:form>
					<h:commandButton style="width:50px; height:30px;"
						image="resources/img/back-button.png"
						action="surveyListForUser.xhtml" immediate="true"></h:commandButton>
					<h:inputHidden value="#{surveyStatsBean.idSurv}" readonly="true" />

					<table cellpadding="10">
						<thead>
							<h3>Survey information</h3>
						</thead>
						<tbody>
							<tr>
								<td><b>Title: </b> <h:outputText
										value="#{surveyStatsBean.surveyDTO.title}" /></td>
								<td><b>Survey period: </b> <h:outputText
										value="#{surveyStatsBean.surveyDTO.startDate}">
										<f:convertDateTime type="date" pattern="dd/MM/yyyy" />
									</h:outputText> - <h:outputText value="#{surveyStatsBean.surveyDTO.endDate}">
										<f:convertDateTime type="date" pattern="dd/MM/yyyy" />
									</h:outputText></td>
							</tr>
							<tr>
								<td><b>Description: </b> <h:outputText
										value="#{surveyStatsBean.surveyDTO.description}" /></td>
								<td><b>Status: </b> #{surveyStatsBean.status}</td>
							</tr>
							<tr>
								<td></td>
								<td><b>Created by:</b> #{surveyStatsBean.userDTO.firstname}
									#{surveyStatsBean.userDTO.lastname}</td>
							</tr>
						</tbody>
					</table>


					<br />


					<h:body
						rendered="#{surveyStatsQTableData.questionList.rowCount == 0}">
						<h2>The current survey has no questions!</h2>
					</h:body>

					<p:dataTable
						rendered="#{surveyStatsQTableData.questionList.rowCount != 0}"
						id="questionsTable" value="#{surveyStatsQTableData.questionList}"
						var="question">

						<p:column>
							<f:facet name="header">
								<h:outputText value="Question"></h:outputText>
							</f:facet>

							<h:outputText value="#{question.questionStatsDTO.text}"
								readonly="true" />
						</p:column>

						<p:column>
							<f:facet name="header">
								<h:outputText value="Option"></h:outputText>
							</f:facet>

							<h:dataTable styleClass="tableStatistics"
								value="#{question.questionStatsDTO.questionOptionStatsArr}"
								var="questionOption">

								<h:column>
									<h:outputText value="#{questionOption.text}" readonly="true" />
								</h:column>

							</h:dataTable>

						</p:column>

						<p:column>
							<f:facet name="header">
								<h:outputText value="Answers"></h:outputText>
							</f:facet>

							<h:dataTable styleClass="tableStatistics"
								value="#{question.questionStatsDTO.questionOptionStatsArr}"
								var="questionOption">

								<h:column>
									<h:outputText value="#{questionOption.percAnswered}"
										readonly="true">
										<f:convertNumber pattern="#0.000" />
									</h:outputText>
								</h:column>

							</h:dataTable>

						</p:column>




					</p:dataTable>

					<br />
					<br />

					<h:commandButton style="width: 100px;"
						rendered="#{surveyStatsQTableData.questionList.rowCount != 0}"
						image="resources/img/pdf.png"
						action="#{surveyStatsQTableData.exportToPdf()}">

						<f:param name="idSurv" value="#{surveyStatsBean.idSurv}">
						</f:param>
					</h:commandButton>

					<h:commandButton style="width: 55px; height: 65px;"
						rendered="#{surveyStatsQTableData.questionList.rowCount != 0}"
						image="resources/img/xls.png"
						action="#{surveyStatsQTableData.exportToXls()}">
						<f:param name="idSurv" value="#{surveyStatsBean.idSurv}">
						</f:param>
					</h:commandButton>

				</h:form>
			</h:panelGroup>
		</h:panelGroup>
	</h:panelGroup>
</h:body>
</html>